package com.itheima.health.dao;

import com.itheima.health.pojo.Order;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderDao {

    //根据id查询数据

    Order selectById(@Param("id") Integer id);

    //查询是否有重复预约 同一人同一天同一套餐
    Long countByMemberAndDateAndSetMeal
            (@Param("MemberId") Integer memberId,
             @Param("OrderDate")Date OrderDate,
             @Param("SetmealId") Integer id);

    //插入数据
    Order insert(Order order);

    /**
     * 根据日期范围统计
     * @param startDate
     * @param endDate
     * @param status null-不限
     * @return
     */
    long countByOrderDateRange(@Param("startDate") Date startDate, @Param("endDate") Date endDate, @Param("status") String status);

    /**
     * 统计前n个预订最多的套餐
     * @param topN
     * @return {"proportion":0.0909,"name":"孕前检查套餐","setmeal_count":1}
     */
    List<Map<String, Object>> countByHotSetMeal(@Param("topN") int topN);
}
